import requests
import time


def send():

    data = {}
    data['diameter'] = '28'
    files = [
        ('originalImg', ('1.jpeg', open('1.jpeg', 'rb'), 'image/jpeg')),
        ('measureImg', ('2.jpeg', open('1.jpeg', 'rb'), 'image/jpeg'))
    ]
    try:
        url = 'http://127.0.0.1:5000'
        print(data)
        resp = requests.post(url, data=data, files=files)
        # 无论发送失败或者成功，文件缓存被清空,需要重新加载
        # time.sleep(4)
        # files = [
        #     ('originalImg', ('1.jpeg', open('1.jpeg', 'rb'), 'image/jpeg')),
        #     ('measureImg', ('2.jpeg', open('1.jpeg', 'rb'), 'image/jpeg'))
        # ]
        #resp = requests.post(url, data=data, files=files)
        jsonResult = resp.json()
        print(jsonResult)
    except Exception as error:
        print(error)
        url = 'http://127.0.0.1:5008'
    pass


send()
